package com.cy.pj.sys.controller;

import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.pojo.Menu;
import com.cy.pj.sys.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shuidehuiyi@gmail.com
 * @date 2020/6/27 18:25
 */
@RestController
@RequestMapping("/menu/")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @RequestMapping("doFindObjects")
    public JsonResult doFindObjects() {
        return new JsonResult(menuService.findObjects());
    }

    @RequestMapping("doDeleteObject")
    public JsonResult doDeleteObject(Integer id) {
        menuService.deleteObjects(id);
        return new JsonResult("delete ok");
    }
    @RequestMapping("doFindZtreeMenuNodes")
    public JsonResult doFindZtreeMenuNodes(){
        return new JsonResult(menuService.findZtreeMenuNodes());
    }

    @RequestMapping("doSaveObject")
    public JsonResult doSaveObject(Menu entity){
        menuService.saveObject(entity);
        return new JsonResult("save ok");
    }
    @RequestMapping("doUpdateObject")
    public JsonResult doUpdateObject(Menu entity){
        menuService.updateObject(entity);
        return new JsonResult("update ok");
    }
}
